----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 48317 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 180
SPELL.m_sName = "Power Kick"
SPELL.m_sToolTip = [[You let loose a devastating
					roundhouse kick, dealing damage
					and knocking back the target.]]
SPELL.m_sIcon = "devin/blackbetty/spells/brawler/powerkick.png"
SPELL.m_bRequiresTarget = true
SPELL.m_iCoolDown = 2
SPELL.m_iManaCost = 30
SPELL.m_iSpellType = SPELLTYPE_MELEEDAMAGE
SPELL.m_bRecastWhileCasting = false

---------------------------------------------------------------------------------------

local range = 100
local weapondamage = 10

function SPELL:Cast( pl, target )
	
	if(target && target:IsValid() && target != pl) then
		pl.InSpellAnimation = true
		pl:DoAnimationEvent(ACT_MP_WALK_PDA)
		pl:EmitSound("devin/blackbetty/player/male/swing_common"..math.random(1,3)..".wav", 100, 100+math.random(-1, -5))
		pl:EmitSound("devin/blackbetty/weapons/slam/swing_"..math.random(1,3)..".wav", 160, 100+math.random(20,30))
		ParticleEffectAttach( "fire_hands_instacast", PATTACH_POINT_FOLLOW, pl, pl:LookupAttachment("rightfoot"))
			timer.Simple(0.1, function()
				if(target and pl:GetPos():Distance(target:GetPos()) < self.m_iRange)then
					if(SERVER)then
						timer.Simple(0.1, function() 
							ParticleEffect( "pummel_hit", target:GetPos() + Vector(0, 0, 48), Angle(0,0,0), target )
							target:EmitSound("devin/blackbetty/weapons/pummel/pummel.wav", 140, 80)
							local dmginfo = DamageInfo()
								dmginfo:SetDamage( 30 ) --50 damage
								dmginfo:SetDamageType( DMG_GENERIC ) --Bullet damage
								dmginfo:SetAttacker( pl ) --First player found gets credit
								dmginfo:SetDamageForce( Vector( 0, 0, 1000 ) ) --Launch upwards
							target:TakeDamageInfo( dmginfo ) 
							target:SetVelocity(((pl:GetPos()- Vector(0, 0, 80)) - target:GetPos())*-4)
						end)
					end
				end
			end)
		timer.Simple(0.55, function()
			pl.InSpellAnimation = false
			pl:SetNWBool("Casting", false)
			pl:SetNWBool("Casted", false)
		end)
	end
end



